<template>
  <div class="menu-container">
    <div class="menu-container-title">
      全部分类
    </div>
    <ul class="menu-container-list">
      <li @mouseleave="leaveLi" @mouseenter="enterLi(index)" v-for="(item, index) of allMenuList.menuList" :key="index">
        <span class="text">{{item}}</span>
        <span class="iconfont">&#xe633;</span>
      </li>
    </ul>
    <div @mouseenter="enterDiv" @mouseleave="leaveDiv" v-show="showHoverList" class="menu-container-hover">
      <div v-for="(item, index) of hoverList" :key="index" class="hover-container">
        <div class="hovers">
          <span>{{item.title}}</span>
          <span>更多<span class="iconfont">&#xe633;</span></span>
        </div>
        <ul class="hover-list">
          <li v-for="(itemTwo, indexTwo) of item.list" :key="indexTwo">{{itemTwo}}</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeMenu',
  data() {
    return {
      hoverList: [],
      /** 展示显示的div */
      showEnterLi: false,
      showEnterDiv: false
    }
  },
  props: {
    allMenuList: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  computed: {
    showHoverList() {
      return this.showEnterLi || this.showEnterDiv
    }
  },
  methods: {
    enterLi(index) {
      this.showEnterLi = true
      /** switch case */
      let list = this.allMenuList.hoverList
      switch (index) {
        case 0:
          this.hoverList = list.hoverMenuListOne
          break
        case 1:
          this.hoverList = list.hoverMenuListTwo
          break
        case 2:
          this.hoverList = list.hoverMenuListThree
          break
        case 3:
          this.hoverList = list.hoverMenuListFour
          break
        case 4:
          this.hoverList = list.hoverMenuListFive
          break
        case 5:
          this.hoverList = list.hoverMenuListSix
          break
        case 6:
          this.hoverList = list.hoverMenuListSeven
          break
        case 7:
          this.hoverList = list.hoverMenuListEight
          break
        case 8:
          this.hoverList = list.hoverMenuListNine
          break
        case 9:
          this.hoverList = list.hoverMenuListTen
          break
        case 10:
          this.hoverList = list.hoverMenuListEleven
          break
        case 11:
          this.hoverList = list.hoverMenuListTwelve
          break
        case 12:
          this.hoverList = list.hoverMenuListThirteen
          break
        case 13:
          this.hoverList = list.hoverMenuListForteen
          break
        case 14:
          this.hoverList = list.hoverMenuListFifteen
          break
        case 15:
          this.hoverList = list.hoverMenuListSixteen
          break
      }
    },
    leaveLi() {
      this.showEnterLi = false
    },
    enterDiv() {
      this.showEnterDiv = true
    },
    leaveDiv() {
      this.showEnterDiv = false
    }
  }
}
</script>

<style lang="scss" scoped>
.menu-container {
  width: 230px;
  position: relative;
  text-align: left;
  box-sizing: border-box;
  float: left;
  margin-top: -50px;
  color: #646464;
  z-index: 100;
  background: #FFF;
  box-sizing: border-box;
  border: 1px solid #E5E5E5;
  &-title {
    font-size: 16px;
    font-weight: bold;
    color: #222;
    padding: 15px;
  }
  &-list {
    display: flex;
    flex-direction: column;
    li {
      display: flex;
      justify-content: space-between;
      height: 26.19px;
      align-items: center;
      color: #646464;
      font-size: 13px;
      padding: 0 10px 0 15px;
      cursor: pointer;
      &:hover {
        background: rgba(255,150,0,0.08);
        color: #222;
        font-weight: bold;
      }
      .iconfont {
        font-size: 9px;
      }
    }
  }
  &-hover {
    position: absolute;
    top: 59px;
    left: 230px;
    width: 390px;
    height: 415px;
    background-color: #fff;
    z-index: 1;
    color: #666;
    .hover-container {
      display: flex;
      flex-direction: column;
      margin-top: 10px;
      &:nth-child(1) {
        margin-top: 0;
      }
      .hovers {
        width: 82%;
        margin: 0 auto;
        padding-top: 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #e5e5e5;
        padding-bottom: 10px;
        span:nth-child(1) {
          color: #222;
          font-size: 15px;
        }
        span:nth-child(2) {
          font-size: 12px;
          color: #999;
          .iconfont {
            font-size: 9px;
          } 
        }
      }
      .hover-list {
        display: flex;
        flex-wrap: wrap;
        width: 82%;
        margin: 0 auto;
        li {
          margin-top: 10px;
          font-size: 12px;
          cursor: pointer;
          color: #999;
          margin-right: 10px;
          &:hover {
            color: #FE8C00;
          }
        }
      }
    }
  }
}
</style>